<template>
  <div class="search">
    <f-form ref="form" :action="api.payconfig" :form-key="this.formItem.payId">
      <f-form-item label="支付名称" name="payName" :required="true" :disabled="true" :value="formItem.payName"/>
      <f-form-item label="AppID" name="appId" :required="true" :value="formItem.appId" v-if="formItem.payCode!='Balance'"/>
      <f-form-item :label="getLabel" name="partner" :required="true" :value="formItem.partner" v-if="formItem.payCode!='Balance'"/>
      <f-form-item label="notifyUrl" name="notifyUrl" :required="true" :value="formItem.notifyUrl" v-if="formItem.payCode!='Balance'"/>
      <f-form-item label="returnUrl" name="returnUrl" :required="true" :value="formItem.returnUrl" v-if="formItem.payCode!='Balance'"/>
      <f-form-item label="seller" name="seller" :value="formItem.seller" v-if="formItem.payCode=='AliPay'"/>
      <f-form-item label="证书路径" name="keystorePath" :value="formItem.keystorePath" v-if="formItem.payCode=='WxPay'"/>
      <f-form-item label="证书密码" name="storePassword" :value="formItem.storePassword" v-if="formItem.payCode=='WxPay'"/>
      <f-form-item label="公钥" name="publicKey" :required="true" type="textarea" :value="formItem.publicKey" v-if="formItem.payCode=='AliPay'"/>
      <f-form-item label="私钥" name="privateKey" :required="true" type="textarea" :value="formItem.privateKey" v-if="formItem.payCode!='Balance'"/>
      <f-form-item label="Logo" type="upload" name="payLogo" :value="formItem.payLogo" :file-max="1"/>
    </f-form>
  </div>
</template>

<script>
  export default {
    name: 'form',
    props: {},
    data() {
      return {
        isAdd: true,
        formItem: this.getFormItem()
      }
    },
    methods: {
      getFormItem() {
        return {
          linkPrefix: '',
          payLogo:''
        }
      },
      setData(data) {
        this.$refs.form.resetFields()
        this.formItem = this.getFormItem()
        this.isAdd = true
        if (data && data.payId) {
          this.formItem = data
          this.isAdd = false
        }
      },
      handleSubmit() {
        this.$refs.form.submit({ payLogo: this.formItem.payLogo })
      }
    },
    computed: {
      getLabel() {
        if (this.formItem.payCode == 'WxPay') {
          return '商户号'
        }
        if (this.formItem.payCode == 'AliPay') {
          return 'PID'
        }
      }
    },
    created() {

    },
    components: {}
  }
</script>

<style scoped lang="less" rel="stylesheet/less">

</style>
